﻿@{
    UserBLL bll = new UserBLL();    
}
<script type="text/javascript">
    var pageid = "@ViewBag.PageInfo.Id";
    $(function () {
        var obj = $("#Meun" + pageid);
        if (obj.length > 0) {
            obj.addClass("active");
            if (obj.find("li").length == 0) {
                obj.parents(".submenu").eq(0).children("a").click();
            }
        }
    });
</script>
<ul>
    @foreach (PageRole item in bll.GetSonPages(0).Where(i => i.Type == "Y" && i.Roles.Contains(string.Format(",{0},", Session["Role"]))))
    {
        List<PageRole> pages = bll.GetSonPages(item.Id).Where(i => i.Type == "Y" && i.Roles.Contains(string.Format(",{0},", Session["Role"]))).ToList();         
        <li id='@("Meun" + item.Id)' @Html.Raw(pages.Count > 0 ? "class='submenu'" : "")><a href="@item.Url">
            <i class="icon icon-list"></i><span>@item.Name</span> </a>
            @if (pages.Count > 0)
            {  
                <ul>
                    @foreach (PageRole info in pages)
                    {
                        <li  id='@("Meun" + info.Id)'><a href="@info.Url">@info.Name</a></li>
                    }
                </ul>
            }
        </li>
    }
</ul>
